{% extends 'base_templates/base.html' %}
{% load static %}

{% block title %}天天生鲜-首页{% endblock title %}

{% block topfiles %}
    <script type="text/javascript" src={% static "static/js/jquery-1.12.4.min.js" %}></script>
    <script type="text/javascript" src={% static "static/js/jquery-ui.min.js" %}></script>
    <script type="text/javascript" src={% static "static/js/slide.js" %}></script>
{% endblock topfiles %}

{% block body %}
    <div class="navbar_con">
        <div class="navbar">
            <h1 class="fl">全部商品分类</h1>
            <ul class="navlist fl">
                <li><a href="{% url 'goods:index' %}">首页</a></li>
                <li class="interval">|</li>
                <li><a href="#">手机生鲜</a></li>
                <li class="interval">|</li>
                <li><a href="#">抽奖</a></li>
            </ul>
        </div>
    </div>
    <div class="center_con clearfix">
        <ul class="subnav fl">
            {% for type in types %}
                <li><a href="#model0{{ forloop.counter }}" class="{{ type.logo }}">{{ type.name }}</a></li>
            {% endfor %}
        </ul>
        <div class="slide fl">
            <ul class="slide_pics">
                {% for image_url in goods_banners %}
                    <li><img alt="幻灯片" src="{{ image_url.image }}"></li>
                {% endfor %}
            </ul>
            <div class="prev"></div>
            <div class="next"></div>
            <ul class="points"></ul>
        </div>
        <div class="adv fl">
            {% for promotion_banner in promotion_banners %}
                <a href="#"><img alt="宣传{{ forloop.counter }}" src="{{ promotion_banner.image }}"></a>
            {% endfor %}
        </div>
    </div>
    {% for type in types %}
        <div class="list_model">
            <div class="list_title clearfix">
                <h3 class="fl" id="model0{{ forloop.counter }}">{{ type.name }}</h3>
                <div class="subtitle fl">
                    <span>|</span>
                    {% for abundance in type.abundant %}
                        <a href="{% url 'goods:detail' abundance.id %}">{{ abundance.name }}</a>
                    {% endfor %}
                </div>
                <a href="{% url 'goods:list' 'default' 1 %}" class="goods_more fr" id="{{ type.logo }}_more">查看更多 ></a>
            </div>
            <div class="goods_con clearfix">
                <div class="goods_banner fl"><img alt="{{ type.name }}" src="{{ type.image.url }}"></div>
                <ul class="goods_list fl">
                    {% for hot in type.hots %}
                        <li>
                            <h4><a href="{% url 'goods:detail' hot.id %}">{{ hot.name }}</a></h4>
                            <a href="{% url 'goods:detail' hot.id %}"><img alt="{{ hot.name }}" src="{{ hot.image.url }}"></a>
                            <div class="prize">¥ {{ hot.price }}</div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    {% endfor %}

    <script type="text/javascript" src={% static "static/js/slide.js" %}></script>
    <script type="text/javascript">
        BCSlideshow('focuspic');
        let oFruit = document.getElementById('fruit_more');
        let oShownum = document.getElementById('show_count');

        let hasorder = localStorage.getItem('order_finish');

        if (hasorder) {
            oShownum.innerHTML = '2';
        }

        oFruit.onclick = function () {
            window.location.href = '../goods/list.html';
        }
    </script>
{% endblock body %}
